define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function ($, undefined, Backend, Table, Form, Template) {
        var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: '/sys/xuqiu/data',
                    add_url: '/sys/xuqiu/add',
                    edit_url: '/sys/xuqiu/edit',
                    del_url: '/sys/xuqiu/del',
                    multi_url: 'data/multi.json',
                    "table": 'page',
                }
            });
            var table = $("#table");
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                sortName: 'id',
                columns: [
                    [
                        {field: 'aaa', checkbox: true},
                        {field: 'id', title: __('id'), operate: false},
                        {field: 'type', title: __('分类'), formatter:function(value, row, index) {
                                if (value == "ys")return "<label class='label label-danger'>月嫂</label>"
                                if (value == "zdg")return "<label class='label label-info'>钟点工</label>"
                                if (value == "dcbj")return "<label class='label label-success'>单次保洁</label>"
                                if (value == "yys")return "<label class='label label-default'>育婴师</label>"
                                if (value == "zjbm")return "<label class='label label-warning'>住家保姆</label>"
                                if (value == "lrph")return "<label class='label label-primary'>老人陪护</label>"
                                if (value == "crs")return "<label class='label label-primary '>催乳师</label>"
                                if (value == "brph")return "<label class='btn btn-outline label-primary '>病人陪护</label>"
                            },searchList:{
                            "ys":"月嫂"
                            ,"zdg":"钟点工"
                            ,"dcbj":"单次保洁"
                            ,"yys":"育婴师"
                            ,"zjbm":"住家保姆"
                            ,"lrph":"老人陪护"
                            ,"crs":"催乳师"
                            , "brph": "病人陪护"
                            }
                            ,operate: true},
                        {field: 'address', title: __('市区'), operate: false},
                     /*   {field: 'cate_id', title: __('分类id'), operate: false},*/
                        {field: 'city_name', title: __('城市'), operate: false},
                        {field: 'contact_type', title: __('联系方式类型'),
                            formatter: function (value) {
                                if (value == 2) {
                                    return "手机"
                                }else{
                                    return value;
                                }
                            },
                            operate: false},
                        {field: 'mobile', title: __('手机'), operate: false},
                        {field: 'service', title: __('服务项目'),formatter:function(value,row,index){
                                if (!value) {
                                    return "";
                                }
                                if (row.type == "zdg") {
                                    value = value.replace("1", "日常保洁");
                                    value = value.replace("2", "洗衣做饭");
                                    value = value.replace("3", "家有萌娃");
                                    value = value.replace("4", "照顾老人");
                                    value = value.replace("5", "其他");
                                }
                                return value;
                            }, operate: false},
                        {field: 'style_bj', title: __('服务项目'),formatter:function(value,row,index){
                                if (!value) {
                                    return "";
                                }
                                return value;
                            }, operate: false},
                     /*   {field: 'coordinate', title: __('坐标'), operate: false},*/
                     /*   {field: 'limit_num', title: __('限制数量'), operate: false},*/
                        {field: 'mianji_bj', title: __('面积'), formatter:function(value,row){
                                console.log(row);
                                if (row.type != 'dcbj') {
                                    return "<label class='label label-danger'>非保洁！</label>"
                                }else{
                                    return "<label class='label label-success'>" + value + "平米</label>";
                                }
                            }, operate: false},
                   /*     {field: 'money', title: __('工资'), operate: false},*/
                        {field: 'money_other', title: __('工资2'), operate: false},
                        {field: 'name', title: __('联系人'), operate: false},
                        {field: 'time_other', title: __('工作时间点'), formatter: function (value, row) {
                                if (row.time == 1) {
                                    return "可谈"
                                }else{
                                    return value;
                                }
                            },operate: false},
                        {field: 'days', title: __('工作天数'), operate: false},
                        {field: 'remarks', title: __('需求备注'),formatter:Table.api.formatter.content,events:Table.api.events.content,operate: false},
                        {field: 'timeline', title: __('时间线'), operate: false},
                        {field: 'create_time', sortable: true, title: __('create_time'), formatter: Table.api.formatter.datetime, operate: 'BETWEEN', type: 'datetime', addclass: 'datetimepicker', data: 'data-date-format="YYYY-MM-DD"'},
                      /*  {field: 'update_time', title: __('update_time'), formatter: Table.api.formatter.datetime, operate:false},*/
                        {field: 'operate', title: __('Operate'), events: Table.api.events.operate, formatter: function (value, row, index) {
                                return Table.api.formatter.operate(value, row, index, table);
                            }
                        }
                    ]
                ],
                //禁用默认搜索
                search: false,
                //启用普通表单搜索
                commonSearch: true,
                //可以控制是否默认显示搜索单表,false则隐藏,默认为false
                searchFormVisible: true,
                exportDataType: 'selected'
            });
            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    Controller.api.bindevent();
    return Controller;
});